import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_1_25_0/testWidget/custom_input_cell.dart';
import 'package:flutter_app_1_25_0/testWidget/data_item_rich_widget.dart';
import 'package:flutter_app_1_25_0/testWidget/data_item_widget.dart';
import 'package:flutter_app_1_25_0/testWidget/image/image_view.dart';
import 'package:flutter_app_1_25_0/testWidget/pb/common/model.pb.dart';
import 'package:flutter_app_1_25_0/testWidget/pb/exercise_practise/model.pb.dart';
import 'package:websafe_svg/websafe_svg.dart';

class RichDataItemPage extends StatefulWidget {
  RichDataItemPage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _RichDataItemPageState createState() => _RichDataItemPageState();
}

class _RichDataItemPageState extends State<RichDataItemPage> {
  List<DataItem> dataList = [];

  @override
  void initState() {
    super.initState();
    String testStr =
        "   Many people are trying to save the earth with special days like“Meatout Day”“Earth day”and “ Buy Nothing Day”．\n   “Meatout Day” is on March 20th. ___ Join this day，and you'll get healthier.Also，you can reduce greenhouse gases and save the earth.\n   ___ Many people all over the world try to do something green on this day.In Italy，people don't use plastic bags.In Canada and Norway，people ride bicycles and don't use their cars.In the USA，people dress up like plants and animals and dance in Times Square，New York.\n    “Buy Nothing Day” is usually on the fourth Friday in November.___\n    “Buy Nothing” means “make no rubbish”.___\n    Do you want to join them？___";
    testStr='Many people are trying to save the earth with special days like Many people are trying to save the earth with special days like Many people are trying to save the earth with special days like';
    for (int i = 0; i < 10; i++) {
      DataItem item = DataItem();
      TextItem textItem = TextItem();
      textItem.style = TextItemStyle.text_item_style_style1;
      textItem.name = '$i $testStr';
      item.text = textItem;
      dataList.add(item);
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Container(
          color: Colors.green,
          width: flexible(context, 860.0),
          child: ListView.builder(
              itemCount: dataList.length,
              itemBuilder: (context, index) {
                return Container(
                  margin: EdgeInsets.only(top: index > 0 ? 20 : 0),
                  color: Colors.redAccent,
                  child: RichDataItemWidget(
                    dataItem: dataList[index],
                    maxLines: 3,
                  ),
                );
              }),
        ),
      ),
    );
  }
}
